Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable dragging feature of slide toc #372

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

IshavSohal
Copy link
Member

@IshavSohal IshavSohal commented Aug 7, 2024

Related Item(s)

#323

Changes

  • Replaced v-model attribute with list attribute
  • Set item-key to a function that returns a slide's title + index within the slides array

Testing

Steps:

  1. Click to edit any storyline, and open dev tools
  2. Proceed to edit existing slides
  3. Try to click and drag any slide up or down
  4. Observe that the slide will be correctly dragged to the desired location.
  5. Also observe there are no 'duplicate key' warnings, implying that the keys are indeed unique

This change is Reviewable

Copy link

github-actions bot commented Aug 7, 2024

Your demo site is ready! 🚀 Visit it here: https://ramp4-pcar4.github.io/storylines-editor/issue-323-fix

Copy link
Member

@yileifeng yileifeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @IshavSohal)

Copy link
Member

@dnlnashed dnlnashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @IshavSohal)

Copy link
Member

@szczz szczz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary blocker. I know the issue mentions that we should disable this functionality, but I think we should at least investigate a resolution to the issue. Additionally, if we do intend to remove it we should probably get rid of the draggable component.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @IshavSohal)

@IshavSohal
Copy link
Member Author

I managed to get the dragging of the toc components to work by using the list prop instead of v-model.

However, I noticed that we're using title as the item key for the draggable component, and that title is not guaranteed to be unique between the slides. This causes 'duplicate key' errors to occur when dragging slides in the toc that have the same title as another slide.

What would be a good solution for this? Perhaps we could state in the schema that the title of a slide has to be unique, as well as ensuring that the title of new slides are unique before adding them in.

Copy link
Member

@yileifeng yileifeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was about to suggest we combine the title + slide index as the key for a simple workaround, but I see that's already being done in the existing code: :key="element.title + index". Does this not work?

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @dnlnashed and @szczz)

@IshavSohal
Copy link
Member Author

IshavSohal commented Aug 12, 2024

It seems like the issues go away when I set item-key to an empty string (in fact any random string). I'm not too sure why that is, as well as if that's problematic.

Copy link
Member

@szczz szczz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean setting the item-key to empty or a random string? I think Yi-Lei's suggestion of title + index would be preferred as we don't want to leave item-key empty. I've tested the dragging functionality and it works well though.

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @IshavSohal)

@IshavSohal
Copy link
Member Author

Yep meant to say item-key, mb. Since I couldn't access the index directly within the draggable component tag, I set item-key to a function that returns the title + index. The 'duplicate key' error should be gone now.

Copy link
Member

@yileifeng yileifeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @IshavSohal)

Copy link
Member

@szczz szczz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @IshavSohal)

@yileifeng yileifeng merged commit 00e9ce1 into ramp4-pcar4:main Aug 29, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants